package cn.gson.crm.model.dao;

import cn.gson.crm.model.pojos.Sell;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

public interface SellDao extends CrudRepository<Sell,Integer> {
    //饼状统计图查询1
    @Query(nativeQuery = true,value = "select count(*) from SELL_ where  Sell_type=?1")
    public Integer sellType(String Type);
    //饼状统计图查询2
    @Query(nativeQuery = true,value= "select count (*) from SELL_ where  SELL_NAME=?1")
    public Integer sellName(String Name);
   //柱形统计图查询销售员工分布情况
    @Query(nativeQuery = true,value = "select b.SELL_MONEY from SELL_ b LEFT JOIN EMPLOYEE f on  b.YG_ID=f.YG_ID WHERE b.SELL_REIMBURSE='已审核'and f.YNAME=?1")
    public List<Integer> selectzhu(String zhu);
    //柱状图查询销售月月份分布
   @Query(nativeQuery = true,value = "select COUNT(*),extract(month from SELL_TIME) month from SELL_ where extract(month from SELL_TIME) = extract(month from SELL_TIME) and SELL_REIMBURSE='已审核' GROUP BY extract(month from SELL_TIME)")
   public List<Integer> selectzhu2(String zhu2);
   //柱状统计图查询费用类型月份分布
   // @Query(nativeQuery = true,value = "select count (*),SELL_TYPE from SELL_ where SELL_TYPE=?1")
   //   public Integer selectzhu2(String zhu1);
}
